package com.huike.business.mapper;

import java.util.Date;
import java.util.List;

import com.huike.business.domain.TbBusiness;
import com.huike.clues.domain.vo.IndexStatisticsVo;
import com.huike.common.core.domain.entity.BusinessChangeStatistics;
import org.apache.ibatis.annotations.Param;

/**
 * 商机Mapper接口
 * @date 2021-04-25
 */
public interface TbBusinessMapper {
    /**
     * 查询商机
     * 
     * @param id 商机ID
     * @return 商机
     */
    public TbBusiness selectTbBusinessById(Long id);
    

    public int countAllBusinessForIndex(IndexStatisticsVo vo);

    /**
     * 查询商机列表
     * 
     * @param tbBusiness 商机
     * @return 商机集合
     */
    public List<TbBusiness> selectTbBusinessList(TbBusiness tbBusiness);

    /*公海池*/
    public List<TbBusiness> selectTbBusinessPool(TbBusiness tbBusiness);

    /**
     * 查询一段时间内的全部由线索转化商机
     * @param code 动态查询条件 当code为1是查询有效商机
     */
    Integer selectBusinessNumByTime(@Param("beginCreateTime") String beginCreateTime,
                        @Param("endCreateTime") String endCreateTime,
                        @Param("code") Integer code);

    /**
     * 每个用户在某个时间段内将多少商机转化为了合同
     */
    BusinessChangeStatistics[] selectEveryUserBusinessChangeNum(
            @Param("beginCreateTime") String beginCreateTime,
            @Param("endCreateTime") String endCreateTime);


    /**
     * 新增商机
     * 
     * @param tbBusiness 商机
     * @return 结果
     */
    public int insertTbBusiness(TbBusiness tbBusiness);

    /**
     * 修改商机
     * 
     * @param tbBusiness 商机
     * @return 结果
     */
    public int updateTbBusiness(TbBusiness tbBusiness);

    public int  resetBusiness(@Param("id") Long id, @Param("status") String status);

    /**
     * 删除商机
     * 
     * @param id 商机ID
     * @return 结果
     */
    public int deleteTbBusinessById(Long id);

    /**
     * 批量删除商机
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteTbBusinessByIds(Long[] ids);

    public int resetNextTimeAndStatus(@Param("id") Long id, @Param("status") String status);


    public int setTransfer(@Param("id") Long id, @Param("status") String status);

	public void updateBusinessEndTimeById(@Param("id")Long id, @Param("endTime")Date endTime);

}
